<?php
require_once "../../php/config/database.php";
require_once "../../php/user/userDb.php";
session_start();
$user = $_SESSION['user'];
$UserDb=new UserDb();
$data=$UserDb->queryUser($user);
$admin=$data[0]['admin'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="shortcut icon" href="../ico/logo.ico" type="image/x-icon" />
    <title>协同办公</title>
    <link rel="stylesheet" href="../../static/css/bootstrap.css">
    <link rel="stylesheet" href="../../static/js/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/font.css">
    <link rel="stylesheet" href="../../static/css/main.css">
</head>
<body>
<div id="logo"><div id="logo-img"><img src="../../static/imaegs/logo/logo2.png"></div>
<div id="logo-right">
    <h5 ><i class="layui-icon" style="font-size: 18px; color: orange">&#xe645;</i>&nbsp;最新公告：<span id="notice">暂无公告</span></h5>
</div>
</div>
<div id="tiao">
    <div id="left"><a href="index.php"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe68e;</i>&nbsp;首页</a>
        <a href="task_list.php"> <i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe6b2;</i>&nbsp;任务</a>
        <a href="index.php"> <i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe637;</i>&nbsp;公告栏</a>
        <a style="color: blue"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe621;</i>&nbsp;文件管理</a>
        <a href="user_list.php"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe613;</i>&nbsp;用户管理</a></div>
    <div id="right"><a style="color:grey" href="../update.php">您好！&nbsp;<i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe66f;</i><input id="user" name="user" readonly="readonly" value="<?php echo $user ?>"></a><a onclick="out()">退出</a></div>
</div>

<div id="from_block">
    <input style="display: none" type="text" id="admin" value="<?php echo $admin; ?>">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">任务附件</li>
            <li>发送的文件</li>
            <li>完成的任务</li>
        </ul>
        <div class="layui-tab-content" style="height: 200px;">
            <div class="layui-tab-item layui-show">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12" id="uul">

                    </div>

                </div>
            </div>
            <div class="layui-tab-item">


                <div class="layui-row layui-col-space15" >
                    <div class="layui-col-md12" id="uull">

                    </div>
                </div>


            </div>
            <div class="layui-tab-item">


                <div class="layui-row layui-col-space15" >
                    <div class="layui-col-md12" id="overTask">

                    </div>
                </div>


            </div>
        </div>
    </div>








</div>
<hr>



<img id="hua1" src="../../static/imaegs/122.png">
<div id="footer">
    <hr>
    <a id="fot-word">
        版权信息：xianghai保留所有权利，请尊重他人的劳动成果   ||    备案号：蜀ICP备18021117号
        ||           地址：四川省成都市高新区天一街83号软件大楼
    </a>
</div>
<script src="../../static/js/jquery.min.js"></script>
<script src="../../static/js/layui/layui.all.js"></script>
<script>


    $user=$('#user').val();
    if($user===""){
        layer.msg("您还没有登陆哦！");
        window.location.href="login.html";

    }

    function xiuGai(){
        window.location.href="update.php";

      }
    var admin=document.getElementById("admin").value;
    $.ajax({
        type: 'post',
        cache: false,
        url: '../../php/admin/select_notice.php',
        data: {
            "user":admin,
        },
        dataType: 'json',
        success: function (data) {
            $dat = data.data;
            $coun = data.count;
            $notice=$dat[0].content;
            var not=document.getElementById("notice");
            not.innerHTML=$notice;

        },
        error: function (data) {
            layer.msg("暂无公告");
        }
    });
    //文件附件查询
    $.ajax({
        type: 'post',
        cache: false,
        url: '../../php/user/select_task_user.php?user='+$user,
        data: {
        },
        dataType: 'json',
        success: function (data) {
            $coun = data.count;
            $dat = data.data;

            for ($i = 0; $i < $coun; $i++) {
                $id = $dat[$i].id;
                $user = $dat[$i].task_admin;
                $title=$dat[$i].title;
                $time=$dat[$i].time_over;
                $task_a=$dat[$i].task_a;
                $user_a=$dat[$i].user_a;
                $remark=$dat[$i].remark;
                $content=$dat[$i].task_content;
                $content=$content.substr(0,30);
                $addtime=$dat[$i].task_time;
                $complete=$dat[$i].complete;
                $url=$dat[$i].url;
                $fileTime=$dat[$i].file_time;
                $file=$dat[$i].file;
                 if($url != ""){
                     $li = $("<div id=" + $id + " class=\"layui-card\" id=\"card\">\n" + "<hr class=\"layui-bg-red\">" +
                         "<div class=\"layui-card-header\">" + "任务：" + $id + "&nbsp;&nbsp;&nbsp;" + $content + "......" +  "<button id='file' class=\"layui-btn layui-btn-xs\" >" + "<a href='" + $url + "' download='' style='color: white'>" + "附件下载" + "</a>" + "</button>" +"<button id='file' class=\"layui-btn layui-btn-primary layui-btn-xs\" >" + "<a href='show.html?id="+$id+"'  style='color: black'>" + "详  情" + "</a>" + "</button>" + "<a id='overTime'>" + "任务截至时间：" + $time + "</a>" + "<a id='overTime'>" + "完成时间：" + $complete + "</a>" + "</div>" +
                         "                       <span id=\"time\">" + "发布时间：" + $addtime + "&nbsp;|&nbsp;" + "发布人：" + $user + "</span>" +
                         "                          <br>\n" +
                         "                    </div>\n" +
                         "                </div>");
                     $("#uul").append($li);
                 }
                 if($file != "0"){
                     $li = $("<div id=" +"l"+ $id + " class=\"layui-card\" id=\"card\">\n" + "<hr class=\"layui-bg-red\">" +
                         "<div class=\"layui-card-header\">" + "任务：" + $id + "&nbsp;&nbsp;&nbsp;" + $content + "......" + "<button id='file' class=\"layui-btn layui-btn-xs\" >" + "<a href='" + $file + "' download='' style='color: white'>" + "文件下载" + "</a>" + "</button>"+"<button id='file' class=\"layui-btn layui-btn-xs layui-btn-normal\" >" + "<a href='show.html?id="+$id+"'  style='color: white'>" + "重新发送" + "</a>" + "</button>" +"<button id='file' class=\"layui-btn layui-btn-primary layui-btn-xs\" >" + "<a href='show.html?id="+$id+"'  style='color: black'>" + "详  情" + "</a>" + "</button>" + "<a id='overTime'>" + "任务截至时间：" + $time + "</a>" + "<a id='overTime'>" + "完成时间：" + $complete + "</a>" + "</div>" +
                         "                       <span id=\"time\">" + "文件上传时间：" + $fileTime + "&nbsp;|&nbsp;任务发布时间："+$addtime+"&nbsp;&nbsp;|&nbsp;"+ "上传者：" + $user_a + "</span>" +
                         "                          <br>\n" +
                         "                    </div>\n" +
                         "                </div>");
                     $("#uull").append($li);


                 }
                if($complete != "未完成"){
                    $li = $("<div id="+"ll" + $id + " class=\"layui-card\" id=\"card\">\n" + "<hr class=\"layui-bg-red\">" +
                        "<div class=\"layui-card-header\">" + "任务：" + $id + "&nbsp;&nbsp;&nbsp;" + $content + "......" + "<button id='file' class=\"layui-btn layui-btn-xs\" >" + "<a href='" + $file + "' download='' style='color: white'>" + "文件下载" + "</a>" + "</button>" +"<button id='file' class=\"layui-btn layui-btn-primary layui-btn-xs\" >" + "<a href='show.html?id="+$id+"'  style='color: black'>" + "详  情" + "</a>" + "</button>" + "<a id='overTime'>" + "任务截至时间：" + $time + "</a>" + "<a id='overTime'>" + "完成时间：" + $complete + "</a>" + "</div>" +
                        "                       <span id=\"time\">" + "发布时间：" + $addtime + "&nbsp;|&nbsp;" + "完成者：" + $user_a + "</span>" +
                        "                          <br>\n" +
                        "                    </div>\n" +
                        "                </div>");
                    $("#overTask").append($li);


                }
                }

        },
        error: function (data) {
            layer.msg("暂无任务");
        }
    });

    //获取管理员的信息
    var user=document.getElementById("user").value;
     function out() {
        layer.confirm('真的要退出吗？', function(index) {
            window.location.href="../../php/user/clearSession.php";
        })
    }

    function del($id,url) {
        layer.confirm('真的删除这个文件么？', function(index) {
            $.ajax({
                type:'post',
                cache:'cache',
                url:'../../php/admin/del_file.php',
                data:{
                    "id":$id,
                    "img":url,
                },
                dataType:'json',
                success:function (dat) {
                    layer.msg(dat.message);
                    var li=document.getElementById($id);
                    li.remove();
                },
                error:function (dat) {
                    layer.msg("删除失败")
                },

            });
        });





    }

    function delFile($id,url) {
        layer.confirm('真的删除这个文件么？', function(index) {
            $.ajax({
                type:'post',
                cache:'cache',
                url:'../../php/admin/del_user_file.php',
                data:{
                    "id":$id,
                    "img":url,
                },
                dataType:'json',
                success:function (dat) {

                    layer.msg(dat.message);
                    id="l"+$id;
                    var li=document.getElementById(id);
                    li.remove();
                },
                error:function (dat) {
                    layer.msg("删除失败")
                },

            });
        });





    }
    function delTask($id,url) {
        layer.confirm('真的删除这个任务和文件么？', function(index) {
            $.ajax({
                type:'post',
                cache:'cache',
                url:'../../php/admin/del_task.php',
                data:{
                    "id":$id,
                    "url":url,
                },
                dataType:'json',
                success:function (dat) {

                    layer.msg(dat.message);
                    id="ll"+$id;
                    var li=document.getElementById(id);

                    li.remove();
                },
                error:function (dat) {
                    layer.msg("删除失败")
                },

            });
        });





    }
    function fileDownload($url) {

        var fileD=document.getElementById("fileD");
        fileD.setAttribute("href",$url);
        fileD.setAttribute("download","file");
    }
</script>

</body>
</html>